DATE/TIME label and rendering for date-only / time-only fields#5521
Conversation
PR Reviewer Guide 🔍(Review updated until commit 0f781da)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 0f781da Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 2b8bb61
Suggestions up to commit 9353fcd
Suggestions up to commit 05a2106
Suggestions up to commit f94cc28
Suggestions up to commit c23f1d5
|
|
Persistent review updated to latest commit c8ca661 |
c8ca661 to
c23f1d5
Compare
|
Persistent review updated to latest commit c23f1d5 |
c23f1d5 to
f94cc28
Compare
|
Persistent review updated to latest commit f94cc28 |
|
LGTM. @vinaykpud Could you also fix the DCO check? I'll wait for analytics-engine side type merge to see how CI passes then. |
f94cc28 to
ec7bf56
Compare
|
Persistent review updated to latest commit ec7bf56 |
ec7bf56 to
05a2106
Compare
Companion to OpenSearch fix/ai/datetime-clusters @ 9009736c2dc. list(<TIME-typed field>) now returns "HH:mm:ss[.fraction]" without the 1970-01-01 epoch-date prefix. The analytics-engine path rewrites PPL list() to DataFusion's list_merge, so the legacy ListAggFunction never fires. Instead, AnalyticsExecutionEngine now post-processes List-typed cells in the result conversion: when an element string matches "1970-01-01[ T]HH:mm:ss[.fraction]", only the time portion is kept. Scalar cells are untouched, preserving the wider timestamp-stringification regression baseline. Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
Recognize the new sandbox DateOnlyType / TimeOnlyType UDT markers in: - OpenSearchTypeFactory.convertAnalyticsEngineRelDataTypeToExprType: DateOnlyType → ExprCoreType.DATE, TimeOnlyType → ExprCoreType.TIME so the user-visible response schema labels span() bucket columns as `date` / `time` instead of `timestamp`. - AnalyticsExecutionEngine.toExprValue: when the column carries a DateOnlyType marker, strip the trailing ` HH:MM:SS` from the Timestamp(ms)-formatted wire value so dates render as `YYYY-MM-DD`. Symmetric handling for TimeOnlyType strips the `1970-01-01 ` prefix. Pairs with the sandbox schema-builder change in opensearch-project/OpenSearch@b69c5ff8888. Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
|
Persistent review updated to latest commit 05a2106 |
… date/time columns On the analytics-engine route a 'date'/'time' column is a TIMESTAMP-backed DateOnlyType/TimeOnlyType marker, so operand-conditional return-type inference mis-read it as TIMESTAMP — ADDDATE(date_col, N) reported (and rendered) TIMESTAMP instead of DATE. Add isDateExprType/isTimeExprType helpers recognizing those markers (off the general conversion path, no substrait round-trip risk) and use them in AddSubDateFunction and PPLReturnTypes.TIME_APPLY_RETURN_TYPE. Fixes the 6 *Null column-operand cases end-to-end. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
05a2106 to
9353fcd
Compare
|
Persistent review updated to latest commit 9353fcd |
Comment trims on top of d12407b (Marc Handalian's cherry-pick) — collapse the multi-line Javadoc on isDateExprType/isTimeExprType to one-line case names, and drop the inline narration at the two call sites (PPLReturnTypes.TIME_APPLY_RETURN_TYPE, AddSubDateFunction#getReturnTypeInference) that restated the helper contract. Behavior unchanged. Signed-off-by: Vinay Krishna Pudyodu <vinkrish.neo@gmail.com>
9353fcd to
2b8bb61
Compare
|
Persistent review updated to latest commit 2b8bb61 |
|
Persistent review updated to latest commit 0f781da |
Summary
Sibling to opensearch-project/OpenSearch#22045. Two
sql/corechanges that complete the PPLDATE/TIMEstory for analytics-engine columns whoseformatmapping is logically date-only or time-only:date/time(nottimestamp).YYYY-MM-DD/HH:mm:ss(no00:00:00suffix on dates, no1970-01-01prefix on times).ADDDATE/SUBDATE/ADDTIME/SUBTIMEover those columns preserveDATE/TIMEas the return type instead of widening toTIMESTAMP.The OpenSearch sandbox PR introduces the
DateOnlyType/TimeOnlyTypeUDT markers and theDateFormatClassifier. This PR teachessql/coreto recognize those markers in three places.Commits
TIME-typed list elements format as HH:mm:ssAnalyticsExecutionEngine.toExprValuestrips the1970-01-01[ T]prefix fromlist()-aggregation elements sostats list(<TIME-typed field>)returns["19:36:22"]instead of["1970-01-01 19:36:22"]. The list path bypasses the sandbox-sideArrowValuesscalar formatter (DataFusion'slist_mergedoesn't carry column-level type hints), so the regex strip lives here.span() output column type for date/time UDTOpenSearchTypeFactory.convertAnalyticsEngineRelDataTypeToExprType:DateOnlyType→DATE,TimeOnlyType→TIME(schema label).AnalyticsExecutionEngine.toExprValue: scalar values strip the midnight time suffix forDateOnlyTypeand the1970-01-01prefix forTimeOnlyType.Preserve DATE/TIME return type for ADDDATE/SUBDATE/ADDTIME/SUBTIME(cherry-pick from @mch2)OpenSearchTypeFactory.isDateExprType/isTimeExprTypehelpers recognize the UDT markers as logicallyDATE/TIME.PPLReturnTypes.TIME_APPLY_RETURN_TYPEandAddSubDateFunctionuse these helpers soADDDATE(date_col, N)reportsDATE(notTIMESTAMP).Query shapes fixed
Test plan
:core:check(compile + unit + spotless + jacoco) green.@AwaitsFixuntil this lands.